<?php

/*
 * 欢迎来到代码世界，如果你想修改多梦主题的代码，那我猜你是有更好的主意了～
 * 那么请到多梦网络（ http://www.dmeng.net/ ）说说你的想法，数以万计的童鞋们会因此受益哦～
 * 同时，你的名字将出现在多梦主题贡献者名单中，并有一定的积分奖励～
 * 注释和代码同样重要～
 * @author 多梦 @email chihyu@aliyun.com 
 */

// 11,30：教授  31：副教授   32：博士、讲师   39：思政老师

if ( in_category(30) ||  in_category(31) ||  in_category(32) ||  in_category(39)) {
    if ( in_category(30) ) {
        $cat_name = single_cat_title('',FALSE);
        $thiscat = get_category(30);
    }elseif (in_category(31)) {
        $cat_name = single_cat_title('',FALSE);
        $thiscat = get_category(31);
    }elseif (in_category(32)) {
        $cat_name = single_cat_title('',FALSE);
        $thiscat = get_category(32);
    }elseif (in_category(39)) {
        $cat_name = single_cat_title('',FALSE);
        $thiscat = get_category(39);
    }
    $parent = get_category($thiscat->category_parent);
    if ($parent->cat_ID==0) {
        $args=array(
          'orderby' => 'id',
          'hide_empty' => 0,
          'order' => 'ASC',
          'parent' => $thiscat->cat_ID
          );
        $categories=get_categories($args);
        header('Location:'.get_category_link($categories[0]->cat_ID));
        exit();     
    }
    $args=array(
      'orderby' => 'id',
      'hide_empty' => 0,
      'order' => 'ASC',
      'parent' => $parent->cat_ID
      );
    $categories=get_categories($args);
    $args=array(
      'orderby' => 'id',
      'hide_empty' => 1,
      'order' => 'ASC',
      'parent' => 65
      );
    $xsuocats=get_categories($args);
}else{
    $thiscats = get_the_category();
    $parent_id=0;
    foreach ($thiscats as  $value) {
        if($value->parent>=$parent_id)
        {
            $parent_id=$value->parent;
            $thiscat=$value;
        }
    }
    if($parent_id!=0){
        $args=array(
        'orderby' => 'slug',
        'hide_empty' => 1,
        'order' => 'ASC',
        'parent' => $parent_id
        );
        $categories=get_categories($args);              
    }
    else {
        $categories=$thiscats;
    }

}

get_header(); ?>

<?php get_header('masthead'); ?>

<?php //get_template_part('nav');?>


<div class="container">
            <div class="page1">
                <div class="row" id="top">
                 <div class="col-md-3 left">
                 <?php 
					foreach((get_the_category()) as $category) {
						$name = $category->cat_name;
					}
                    if ( in_category(30) ||  in_category(31) ||  in_category(32) ||  in_category(39)) {
                            $name = '师资队伍';
                        }
                 ?>
                    <h2 class="h2-set"><?php echo $name; ?></h2>
                 </div>
                 
                </div>
                <div class="row" id="middle">
                    <div class="col-md-3 ">
                    <div class="row">
                        <div class="sidebar">
                            <ul>

                        <?php foreach ($categories as $category)
                        {
                            if ($category->cat_ID==$thiscat->cat_ID)
                            {
                                $str = '<li class="submenu-hover">';
                            }
                            else
                            {
                                $str = '<li>';
                            }
                            $str .= "<a href=\"".get_category_link($category->cat_ID)."\" title=\"$category->name\" >$category->name</a></li>";
                            echo $str;
                         }?>  
                            </ul>
                        </div>
                        </div>
                    </div>

                    
                    <div class="col-md-9">
                        <div class="page-detail">
                           <div class="detail-title">
                               <p><?php echo get_the_title(); ?></p>
                           </div>
                           <div class="detail-category">
                             
                               <ul>
                               <li><span class="glyphicon glyphicon-folder-open"></span></li>
                               <li>&nbsp;&nbsp;</li>
                               <li>
									<?php
										if(function_exists('bcn_display')) {
											bcn_display();
										}
									?>
                                </li>


                               </ul>
                               <div class="detail-text">
                               
									<?php 
										while ( have_posts() ) : the_post();
											//get_template_part('content');
										echo '<p>'.the_post_thumbnail('large').'</p>';
                                        the_content();
										endwhile; 
										//dmeng_paginate();
									?>
                                </div>

                           </div>
                        </div>
                    </div>
                </div>
            </div>
</div>


<?php get_footer(); ?>


